from Crypto.PublicKey import RSA #管理公钥和私钥的包
rsa_key = RSA.generate(2048)
private_key = rsa_key.exportKey()
public_key = rsa_key.publickey().exportKey()
# print(private_key)
# print(public_key)#打印后发现private_key和public_key是二进制数据
with open('private_key.txt',mode='wb') as f:
    f.write(private_key)
with open('public_key.txt',mode='wb') as f:
    f.write(public_key)
